#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

// 2024-04-22

// --------- p6 ---------
int factorial(int);
int combination(int, int);
int gcd(int, int);

int main(void)
{
	printf("%d\n", factorial(23));
	printf("%d\n", combination(23, 5));
	printf("%d\n", gcd(243, 66));

	return 0;
}

int factorial(int n)  // p6
{
	int result = 1;
	for (int i = 2; i < n + 1; i++)
		result *= i;
	return result;
}
int combination(int n, int r)  // p7
{
	if (n == r || r == 0)  return 1;
	else                   return combination(n - 1, r - 1) + combination(n - 1, r);
}
int gcd(int x, int y)  // p8
{
	int max = (x < y) ? y : x;
	int min = (x < y) ? x : y;
	if (max / min == 1)  return 1;
	else                 return (max / min) * gcd(max - min * (max / min), min);
}

